]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
util: Add lerp function
authorGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>
Thu, 31 Dec 2020 17:18:42 +0000 (14:18 -0300)
committerMarge Bot <marge-bot@gnome.org>
Fri, 29 Jan 2021 15:01:03 +0000 (15:01 +0000)
We're going to lerp a lot in the future, to it's worthy sharing
this simple but effective interpolation function.

Add Util.lerp().

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1593>

js/misc/util.js

index 314d7660f6eb5145ed58b8e2307974b81bd5bbbb..2da489bbe64d08bcfac379fd49f86b937a8d3f5d 100644 (file)
@@ -1,7 +1,7 @@
 // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
 /* exported findUrls, spawn, spawnCommandLine, spawnApp, trySpawnCommandLine,
             formatTime, formatTimeSpan, createTimeLabel, insertSorted,
-            ensureActorVisibleInScrollView, wiggle */
+            ensureActorVisibleInScrollView, wiggle, lerp */
 
 const { Clutter, Gio, GLib, Shell, St, GnomeDesktop } = imports.gi;
 const Gettext = imports.gettext;
@@ -435,3 +435,7 @@ function wiggle(actor, params) {
         },
     });
 }
+
+function lerp(start, end, progress) {
+    return start + progress * (end - start);
+}